import { createRouter, createWebHistory } from 'vue-router';
import Home from '@/views/Home.vue';

const routes = [
  {
    path: "/login",
    name: "Login",
    component: () => import("@/views/Login.vue"),
  },
 {
    path: '/register',
    name: 'Register',
    component: () => import('@/views/Register.vue'),  // 动态导入 Register 组件
  },
  {
    path: '/',
    name: 'Home',
    component: Home,
    children: [
      {
        path: '',
        name: 'HomeContent',
        component: () => import('@/views/HomeContent.vue'),
      },
      {
        path: 'categorymenu',
        name: 'CategoryMenu',
        component: () => import('@/components/CategoryMenu.vue'),
      },
      {
        path: 'goods',
        name: 'GoodsList',
        component: () => import('@/components/GoodsList.vue'),
      },
      {
        path: 'userprofile',
        name: 'UserProfile',
        component: () => import('@/components/UserProfile.vue'),
      },
    ],
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

export default router;
